import numpy as np

# 创建向量
arr1 = np.arange( 1,10 )
print( arr1 )  # [1 2 3 4 5 6 7 8 9]

# 访问元素
print( arr1[3] ) # 正着访问 4
print( arr1[-1] ) # 倒着访问 9

# 修改数组元素
arr1[3] = 100;
print( arr1 ) # [  1  2  3 100   5   6   7   8   9]

# 访问矩阵
# 创建矩阵
arr2 = np.array( [ [1,2,3],[4,5,6] ] )
print(arr2)
"""
[[1 2 3]
 [4 5 6]]
"""
# 访问元素
print( arr2[0,2] )  # 3
print( arr2[1,-2] ) # 5
# 修改元素
arr2[1,1] = 100.9
print( arr2 )
"""
[[  1   2   3]
 [  4 100   6]]
"""
